require(['init'], function () {
  var answer=UE.getEditor('answer');
  var taskid = location.search.urlToObj().taskid;
  var studentuid=location.search.urlToObj().studentuid;
  var id=location.search.urlToObj().id;
   //获取老师布置作业和上课的返回信息
    $.ajax({
       url:' /api/task/subject/'+taskid ,
       type:'get',
       success:function(data){
         var data=data.data;
         $('.job_title').html(data.title);
         $('.job_content').html(data.content);
         $('.job_content').find('a').attr('target','_blank');
         $('.classroom_feedback').html(data.note);
         var scheduleid=data.scheduleid;
         var classeid=data.classeid;
         $.ajax({
           url:'/api/schedule/'+scheduleid,
           type:'get',
           success:function(datat){
             $('.lessonname').html(datat.data.name)
           }
         })
         if(data.classetype==2){
           $.ajax({
             url:'/api/classe/'+classeid,
             type:'get',
             success:function(json){
               console.log(json)
               $('.classname').html(json.data.classname)
             }
           })

         }else if(data.classetype==1){
           $('.classname').html(i18next.t('table.aboutclass'));//约课
         }
     }
   })
   //提交作业
  var $submit_html=$('#submit_html');
    $submit_html.on('click',function(){
     var content=answer.getContent();
     if(content!=""){
        var popUpBox=new PopUpBox({
         type:'dom',
         style:'default contentScroll',
         submitBtnType:'confirm',
         titleText:i18next.t('popupbox.systemprompt'),//系统提示
         drag:true,
         show:true,
         content:'<div style="margin-top:20px;padding-left:16px;color:#818e9b">'+i18next.t('popupbox.answer')+'</div>',//请确认答案是否正确，提交之后不可更改！
         callback:{
           yes: function (e) {
               ajaxMethod({
                 url: '/api/task/reply/'+id+'/commit', // 这里的id是作业list的id
                 type: 'put',
                 data: {
                   content:content,
                 },
                 success: function (data) {
                   window.location.href="job_title.html";
                 }
               });
           }
         },
         position:{
           width:446,
           height:265
           }
         })
         $('.confirm').find('.btn-default').css({
          "border": "1px solid #ccc",
         })
      }else{
        var popUpBox=new PopUpBox({
         type:'dom',
         style:'default contentScroll',
         submitBtnType:'confirm',
            titleText:i18next.t('popupbox.systemprompt'),//系统提示
         drag:true,
         show:true,
         content:'<div style="margin-top:20px;padding-left:16px;color:#818e9b">'+i18next.t('popupbox.fillanswer')+'</div>',//请填写您的答案！
         callback:{
           yes: function (e) {
           }
         },
         position:{
           width:446,
           height:265
           }
         })
        return false;
      }
   })
})
